<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var r =""
    var level = prompt("请输入层数：")
    level = parseInt(level)
    for(var i=1;i<=level;i++)
 {
    for(var j=1;j<=level-i;j++)
 {
    r+=" "
 }
 for(var k=1;k<=i*2-1;k++)
 {
    r+="*"
 }
 r+="\n"
  }
 console.log(r)
</script>
</html>